-- penetrate_damage
-- create by shuzy
-- 单体，对目标造成伤害，且造成的伤害忽视一定抗性

return {
    apply = function(source, target, skillId, round, para, extra)
        -- 攻击方的基础攻击
        local attack = InterfaceM.calcBaseAttrib(source, "attack");

        -- 被对方百分比削弱
        local prop = PropM.combine(target, "weak_enemy", "attack");
        attack = PropM.apply(prop, attack);

        -- 被对方绝对值削弱
        prop = PropM.combine(target, "weak_enemy2", "attack");
        attack = PropM.apply(prop, attack);

        -- 威力
        local force = para[1];
        -- 伤害
        local damage = math.modf(force * attack / 1000);

        -- 魔法抗性
        prop = PropM.combine(target, "resist", "magic");
        -- 本技能忽视的抗性
        prop[3] = math.max(0, prop[3] - para[2]);
        -- 忽视抗性
        local p = PropM.combine(source, "ignore_resist", skillId);
        prop[3] = PropM.apply(p, prop[3]);
        p = PropM.combine(source, "ignore_resist", "magic");
        prop[3] = PropM.apply(p, prop[3]);
        -- 天赋概率无视抗性
        local p = PropM.combine(source, "disre_resist", skillId);
        local seed = DungeonM.getRandSeed("disre_resist");
        if seed % 1000 < PropM.apply(p, 1) then
            prop[3] = 0;
        end

        damage = PropM.apply(prop, damage);

        -- 增加命中动作
        SkillM.getSequence(target):hit(source, target, skillId);
        -- 伤害
        CombatM.doDamage(source, target, damage, skillId, nil, extra);

        -- 作用目标
        return { target, };
    end,

    parse = function(desc)
        local arr = string.explode(desc, ",");
        return { tonumber(arr[1]), tonumber(arr[2]) };
    end,

    -- 解析技能描述
    parseDesc = function(source, skillId, desc, para)
        -- 攻击方的基础攻击
        local attack = InterfaceM.calcBaseAttrib(source, "attack");

        -- 威力
        local force = para[1];

        -- 伤害
        local damage = math.modf(force * attack / 1000);

        desc = string.gsub(desc, "{penetrate_damage}", damage);

        return desc;
    end,
};
